<!--********************************************************************
* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_wmtsLayer"></title>
    <!-- <script type="text/javascript" src="../js/include-web.js"></script> -->
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
    <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="https://iclient.supermap.io/dist/leaflet/iclient-leaflet.min.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";

    // EPSG:4326 的分辨率和原点通常与 EPSG:3857 不同
    // 需要根据 SuperMap 服务的 TileMatrixSet 配置进行调整，例如 GlobalCRS84Scale
    var resolutions_4326 = [];
     for (var i = 0; i < 20; i++) {
         // 这里的计算需要参考 SuperMap GlobalCRS84Scale 的定义
         // 示例中使用一个简化的计算，实际值应查阅服务 Capabilities 文档
         resolutions_4326.push(0.703125 / Math.pow(2, i));
     }

    var map = L.map('map', {
        center: [35, 105], // 适当调整中心点
        maxZoom: 20, // 根据TileMatrixSet调整最大缩放级别
        zoom: 4, // 适当调整缩放级别
        crs: new L.supermap.Proj.CRS("EPSG:4326",
            {
                origin: [-180.0, 90.0], // 根据TileMatrixSet提供的TopLeftCorner设置原点
                resolutions: [
                     1.25764139776733, // Level 0 resolution
                     0.628820698883665, // Level 1 resolution
                     0.251528279553466, // Level 2 resolution
                     0.125764139776733, // Level 3 resolution
                     0.0628820698883665, // Level 4 resolution
                     0.0251528279553466, // Level 5 resolution
                     0.0125764139776733, // Level 6 resolution
                     0.00628820698883665, // Level 7 resolution
                     0.00251528279553466, // Level 8 resolution
                     0.00125764139776733, // Level 9 resolution
                     6.28820698883665E-4, // Level 10 resolution
                     2.51528279553466E-4, // Level 11 resolution
                     1.25764139776733E-4, // Level 12 resolution
                     6.28820698883665E-5, // Level 13 resolution
                     2.51528279553466E-5, // Level 14 resolution
                     1.25764139776733E-5, // Level 15 resolution
                     6.28820698883665E-6, // Level 16 resolution
                     2.51528279553466E-6, // Level 17 resolution
                     1.25764139776733E-6, // Level 18 resolution
                     6.28820698883665E-7, // Level 19 resolution
                     2.51528279553466E-7  // Level 20 resolution
                 ],
                bounds: L.bounds([-180.0, -85.0511287798065], [180.0, 85.05112877980648]) // 使用提供的精确边界
            })
    });

    new L.supermap.WMTSLayer(host + "/iserver/services/map-china400/wmts100",
        {   // 针对 EPSG:4326 服务调整参数
            layer: "China_4326", // 通常图层名称也会带有坐标系信息
            style: "default",
            tilematrixSet: "GlobalCRS84Scale_China_4326", // 使用服务实际的 TileMatrixSet Identifier
            format: "image/png",
            requestEncoding: 'REST',
            attribution: "Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span>"
        }
    ).addTo(map);

</script>
</body>
</html> 